# -*- coding:utf-8 -*-
import os,sys
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import (QApplication)
from app.model.model import AppModel
from app.controller.controller import AppController
from app.view.view import AppView
from app.common.global_config import GlobalConfig

basedir = os.path.dirname(__file__)
resourcesdir = os.path.join(basedir,"resources")

def main():
    # 加载配置文件
    global_config = GlobalConfig.get_instance()
    global_config.load_config()
    # 初始化UI
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon(os.path.join(resourcesdir, "icon.png")))
    model = AppModel()
    view = AppView()
    controller = AppController(model, view)
    # 通过配置信息，初始化记录的数据
    model.init_model(global_config.data)
    
    view.show()
    sys.exit(app.exec())

if __name__ == "__main__":
    main()